package com.learn.design.strategy;

import org.apache.commons.lang3.StringUtils;
import org.thymeleaf.expression.Maps;

import java.util.HashMap;
import java.util.Map;

/**
 * 工廠模式
 *
 */
public class Factory {

    public static Map<String,CalculateHandler> calculateHandlerMap = new HashMap<>();

    public static CalculateHandler getCalculateHandler(String name) {
        return calculateHandlerMap.get(name);
    }

    public static void register(String name,CalculateHandler handler){
        if(StringUtils.isBlank(name) || handler == null){
            return;
        }
        calculateHandlerMap.put(name,handler);
    }
}
